// AnalysisController.java
package com.sulent.frame.web.controller.test;

import com.sulent.frame.web.service.AnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;

@RestController
@RequestMapping("/api/analysis")
public class AnalysisController {

    @Autowired
    private AnalysisService analysisService;

    @PostMapping("/parallel")
    public Map<String, Object> triggerParallelAnalysis(@RequestBody Map<String, Object> input) {
        try {
            return analysisService.performAnalysis(input);
        } catch (InterruptedException | ExecutionException | TimeoutException e) {
            // 处理异常，例如返回部分结果或错误信息
            return (Map<String, Object>) new HashMap<>().put("error", e.getMessage());
        }
    }
}